package com.zl.aop;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

/**
 * @author ZLL
 * @date create in 2018/05/09
 */
public class TestAopAspect {


        public void doBefore(JoinPoint joinpoint){
            System.out.println("doBefore====>"+joinpoint.getTarget().getClass().getName());
            System.out.println("doBefore====>"+joinpoint.getSignature().getName());
        }

        public void doAfter(){
            System.out.println("doAfter.......");
        }

        public void doAround(ProceedingJoinPoint proceedingJoinPoint){
            System.out.println("在方法之前做点事。。。");
            try {
                Object ret = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs());
                System.out.println("doAround>>>>"+ret);
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
            System.out.println("在方法之后做点事。。。");
        }

        public void doAfterReturning(JoinPoint joinPoint){
            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
            Class<?> returnType = signature.getMethod().getReturnType();
            System.out.println("doAfterReturning........"+returnType);
        }

        public void doThrowIng(Throwable ex){
            System.out.println("doThrowIng....."+ex.getMessage());
        }

}
